#ifndef _AIR_CONTACTLISTENER_
#define _AIR_CONTACTLISTENER_

#include "aerial\Game\GameObject\GameObject.h"

#include "Box2D\Box2D.h"
#include <set>

using namespace std;

struct ContactObject {
	GameObject* a;
	GameObject* b;

	ContactObject(): a(0), b(0) {}
	ContactObject(GameObject* _a, GameObject* _b): a(_a), b(_b) {}
	bool operator == (const ContactObject& rhs) const { 
		return a->id == rhs.a->id && b->id == rhs.b->id; 
	}
	bool operator < (const ContactObject& rhs) const { 
		return a->id < rhs.a->id || a->id == rhs.a->id && b->id < rhs.b->id; 
	}
};

class AirContactListener: public b2ContactListener
{
public:
	void BeginContact(b2Contact* contact);
	void EndContact(b2Contact* contact);
	void process(float dt);
	void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);
	//void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) {}
private:
	set<ContactObject> ContactSet;
};

#endif